<?php

class Webmix_Form_Admin_Settings_Level extends Authorization_Form_Admin_Level_Abstract
{
  public function init()
  {
    parent::init();
	
  // Change description decorator
    $this->loadDefaultDecorators();
    $this->getDecorator('Description')->setOptions(array('tag' => 'h4', 'placement' => 'PREPEND'));

    // Prepare user levels
    $levelOptions = array();
    foreach( Engine_Api::_()->getDbtable('levels', 'authorization')->fetchAll() as $level ) {
      	if($level->level_id == 5) continue;
    	$levelOptions[$level->level_id] = $level->getTitle();
    }

    // Element: level_id
    $this->addElement('Select', 'level_id', array(
      'label' => 'Member Level',
      'multiOptions' => $levelOptions,
      'onchange' => 'javascript:fetchLevelSettings(this.value);',
      'ignore' => true,
    ));


    
    // My stuff
    $this
      ->setTitle('Member Level Settings')
      ->setDescription("WEBMIX_FORM_ADMIN_LEVEL_DESCRIPTION");

    //if( !$this->isModerator() ) {
      unset($this->view->options[1]);
   // }

    if( !$this->isPublic() ) {
      // Element: max
      $this->addElement('Text', 'max', array(
        'label' => 'Maximum Allowed Webmixes?',
        'description' => 'Enter the maximum number of allowed webmixes. The field must contain an integer between 1 and 999, or empty for unlimited.',
        'validators' => array(
          array('Int', true),
          new Engine_Validate_AtLeast(0),
        ),
      ));
    }
  }
}